<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="{:url('SchoolDistrict/index')}">校区管理</a></li>
        <li><a href="{:url('SchoolDistrict/add')}">添加校区</a></li>
    </ul>
    <div class="row margin-top-20">
        <div class="col-md-2">
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <div class="checkbox">
                        <label>
                            <input type="radio" name="is_school" value="2" id="Js_radioSchool" > 学校
                        </label>
                        <label>
                            <input type="radio"  name="is_school" value="1" id="Js_radioArea" checked> 地区
                        </label>
                    </div>
                </div>
            </div>
        </div>
        <!--校区-->
        <div class="col-md-6" id="Js_schoolbox" style="display: none;">
            <form class="js-ajax-form" action="{:url('SchoolDistrict/addPost')}" method="post">
                <div class="tab-content">
                    <div class="tab-pane active" id="A">
                        <div class="form-group">
                            <label for="input-parent"><span class="form-required">*</span>上级</label>
                            <div>
                                <select class="form-control" name="parent_id" id="input-parent">
                                    <option value="0">作为一级分类</option> {$categories_tree}
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="input-name"><span class="form-required">*</span>校区名称</label>
                            <div>
                                <input type="text" class="form-control" id="input-name" name="name">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="input-name1">校区地址</label>
                            <div>
                                <input type="text" class="form-control" id="input-name1" name="address">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="input-name2">校区交通</label>
                            <div>
                                <input type="text" class="form-control" id="input-name2" name="traffic">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="input-name3">咨询电话</label>
                            <div>
                                <input type="text" class="form-control" id="input-name3" name="phone">
                            </div>
                        </div>
                        <div class="form-group" >
                            <label for="input-name4">服务时间</label>
                            <div id="class_time_tr">
                                <input type="text" class="form-control" id="input-name4" name="service_time" >
                                <input type="hidden" name="is_school" value="0" id="radio_status1">
                                <!--<a  class="btn btn-success" id="Js_add">添加多个服务时间</a>-->
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <button type="submit" class="btn btn-primary js-ajax-submit">{:lang('ADD')}</button>
                    <a class="btn btn-default" href="{:url('SchoolDistrict/index')}">{:lang('BACK')}</a>
                </div>
            </form>
        </div>
        <!--地区--上海-->
        <div class="col-md-6" id="Js_arealbox">
            <form class="js-ajax-form" action="{:url('SchoolDistrict/addPost')}" method="post">
                <div class="tab-content">
                    <div class="tab-pane active">
                        <div class="form-group">
                            <label for="input-parent1"><span class="form-required">*</span>上级</label>
                            <div>
                                <select class="form-control" name="parent_id" id="input-parent1">
                                    <option value="0">作为一级分类</option> {$categories_tree}
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="input-name12"><span class="form-required">*</span>地区名称</label>
                            <div>
                                <input type="text" class="form-control" id="input-name12" name="name">
                                <input type="hidden" name="is_school" value="1" id="radio_status2">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <button type="submit" class="btn btn-primary js-ajax-submit">{:lang('ADD')}</button>
                    <a class="btn btn-default" href="{:url('SchoolDistrict/index')}">{:lang('BACK')}</a>
                </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript" src="__STATIC__/js/admin.js"></script>
<script>
    $(function()
    {

        $("#Js_radioSchool").click(function() {
           var val=$("#Js_radioSchool").val();
            $("#Js_schoolbox").css("display",'block');
            $("#Js_arealbox").css("display",'none');

        })
        $("#Js_radioArea").click(function() {
            var val=$("#Js_radioSchool").val();
            $("#Js_schoolbox").css("display",'none');
            $("#Js_arealbox").css("display",'block');

        })
        //服务时间段的添加
        $("#Js_add").click(function()
        {
            $class_start_week_show='';
            $class_start_week=$("#input-name4").val();
            if($class_start_week==''){
                alert('时间为空');
                return false;
            }
            $('<tr><th></th><td>' +
                    '<div class="col-sm-3" style="padding-left:0px;"> ' +
                    '<input type="hidden"  class="form-control" name="service_time[]" value="'+$class_start_week+'" readonly>' +
                    '<input type="text"  class="form-control" value="'+$class_start_week+'" readonly></div>' +
                    ' <div class="col-sm-6">' +
                    ' <a href="javascript:" class="btn btn-success cancel">取消</a> </div></td></tr>').insertAfter($("#class_time_tr"));
            $("#input-name4").val('');
        })
        //取消
        $("body").on("click",'.cancel',function(){
            $(".cancel").parents('tr').remove();
        })
    })
</script>
</body>
</html>